/**
 * Created with JetBrains PhpStorm.
 * User: vander
 * Date: 6/13/13
 * Time: 9:20 PM
 * To change this template use File | Settings | File Templates.
 */
$j("#mainPage").on("pageinit", function(event){
    Global.collections = new Collections();
    $j.mobile.loading( 'show');
    $j.getJSON(Static.serverPath + "getStoreCollection.php", function(data){
        Global.collections.load(data);
        $j.mobile.loading( 'hide');
    });
});

$j("#deleteConfirm a.yes").on("click", function(){
    $j.get(Static.serverPath + "deleteBook.php", {bookId: Global.collections.selectedBookIdToDelete}, function(data){
        if(data == "true"){
            Global.collections.remove(Global.collections.selectedBookIdToDelete);
        }
    });
});

$j("#refreshButton").on("click", function(){
    $j.mobile.loading( 'show');
    $j.getJSON(Static.serverPath + "getStoreCollection.php", function(data){
        Global.collections.load(data);
        $j.mobile.loading( 'hide');
    });
});